package com.ydzh.kfqgwvisitor.controller;


import com.ydzh.kfqgwvisitor.base.Result;
import com.ydzh.kfqgwvisitor.dto.VisitorDTO;
import com.ydzh.kfqgwvisitor.dto.VisitorFaceDTO;
import com.ydzh.kfqgwvisitor.entity.Visitor;
import com.ydzh.kfqgwvisitor.response.Response;
import com.ydzh.kfqgwvisitor.service.VisitorService;
import com.ydzh.kfqgwvisitor.vo.VisitorVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 访客信息表  前端控制器
 * </p>
 *
 * @author zcj
 * @since 2021-09-01
 */
@RestController
@RequestMapping("/visitor")
@Api(tags = "访客信息")
public class VisitorController {

    @Autowired
    private VisitorService visitorService;

    @GetMapping("/confirm/{id}")
    @ApiOperation(value = "被访人通过访客申请")
    public Result confirm(@ApiParam(name = "id", value = "主访客人的id", required = true) @PathVariable("id") Long id) {

        return visitorService.confirm(id);

    }

    @GetMapping("/refuse/{id}")
    @ApiOperation(value = "被访人拒绝访客申请")
    public Result refuse(@ApiParam(name = "id", value = "主访客人的id", required = true) @PathVariable("id") Long id) {

        return visitorService.refuse(id);

    }


    @ApiOperation(value = "访客申请")
    @PostMapping("/apply")
    public Result apply(@Validated @RequestBody VisitorDTO visitorDTO) {
        return visitorService.saveToApply(visitorDTO);
    }


    @ApiOperation(value = "获得陪同人员信息")
    @GetMapping("/follower/{id}")
    public Result<Visitor> apply(@ApiParam(name = "id", value = "陪同人员的ID", required = true) @PathVariable("id") Long id) {
        return Result.buildSuccess(visitorService.getById(id));
    }

    @PostMapping("/applyFace")
    public Result apply(@Validated @RequestBody VisitorFaceDTO visitorFaceDTO) {
        return visitorService.applyFace(visitorFaceDTO);
    }

    @ApiOperation(value = "管委领导获得访客信息")
    @GetMapping("/visitorInfo/{visitorId}")
    public Result<VisitorVO> visitorInfo(@ApiParam(name = "visitorId", value = "访客人的ID", required = true) @PathVariable("visitorId") Long visitorId) {
        return visitorService.visitorInfo(visitorId);
    }

   /* @ApiOperation(value = "通过身份证照片获得身份证信息")
    @PostMapping("/idCardInfo")
    public Result<IDCardVo> idCardInfo(@RequestBody String img) {
        return visitorService.idCardInfo(img);
    }

    @ApiOperation(value = "活体验证")
    @PostMapping("/faceverify")
    public Result faceverify(@RequestBody String img) {
        return visitorService.faceverify(img);
    }*/


    @ApiOperation(value = "点击链接生成访客海康数据")
    @GetMapping(value = "/QRCode/{id}")
    public Result QRCode(@ApiParam(name = "id", value = "主访客人的ID", required = true) @PathVariable("id") Long id) throws Exception {

        return Result.buildSuccess(visitorService.getQRCode(id));
    }

    @ApiOperation(value = "点击链接生成访客卫健委数据")
    @GetMapping(value = "/HealthCode/{id}")
    public Response HealthCode(@ApiParam(name = "id", value = "主访客人的ID", required = true) @PathVariable("id") Long id) throws Exception {

        return visitorService.getHealthCode(id);
    }

    @PostMapping("/upload")
    public Result upload(@RequestParam("file") MultipartFile multipartFile) throws Exception {
        return visitorService.upload(multipartFile);
    }
}

